package com.lagou.edu.controller;

import com.lagou.edu.entity.Order;
import com.lagou.edu.service.OrderService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.RequestMapping;

import java.util.concurrent.ExecutionException;

/**
 * @author 赵虎
 * @date 2021/4/1 1:43 上午
 */
@Controller
public class OrderController {
    @Autowired
    private OrderService orderService;

    /**
     * 发起一个订单
     */
    @RequestMapping("/order")
    public String order(Model model) throws ExecutionException, InterruptedException {
        Order order = new Order();
        boolean b = orderService.addOrder(order);
        model.addAttribute("orderId", order.getId());
        return b ? "order" : "failorder";
    }
}
